package com.start.shop.api.vo.order;

import java.math.BigDecimal;
import java.util.Date;

import com.start.shop.common.constant.ApiFeildCode;
import com.start.shop.common.constant.TableFeildCode;
import com.start.shop.modules.repository.entity.Order;

import lombok.Data;

@Data
public class OrderVo {
	private String orderNo;
	private OrderSkuVo goods; //订单商品信息
	private OrderCouponVo conpon; //订单使用的优惠券
	private BigDecimal actulAmt;  //实际支付
	private OrderAddress address;
	private String status;
	private String payNo;
	private Date payTime;
	private String deliveryNo;
	private Date deliveryTime;
	private Date createTime;
	
	
	public static OrderVo setData(Order order) {
		
		//返回的订单商品信息
		OrderSkuVo orderSkuVo = new OrderSkuVo();
		orderSkuVo.setGoodsId(order.getGoodsId());
		orderSkuVo.setGoodsType(order.getGoodsType());
		orderSkuVo.setGoodsName(order.getGoodsName());
		orderSkuVo.setBuyCnt(order.getBuyCnt());
		orderSkuVo.setSkuAmt(order.getSkuPrice());
		orderSkuVo.setSkuId(order.getSkuId());
		orderSkuVo.setTotalAmt(order.getTotalAmt());
		orderSkuVo.setSkuImg(order.getSkuImg());
		
		//返回的订单优惠券信息
		OrderCouponVo orderCouponVo = new OrderCouponVo();
		orderCouponVo.setCouponId(order.getCouponId());
		orderCouponVo.setCouponName(order.getCouponName());
		orderCouponVo.setCouponDesc(order.getCouponDesc());
		orderCouponVo.setCouponAmt(order.getCouponAmt());
		
		//地址信息
		OrderAddress orderAddress= new OrderAddress();
		orderAddress.setAddress(order.getPostAddress());
		orderAddress.setPostMobile(order.getPostMobile());
		orderAddress.setPostName(order.getPostName());
		
		//组织order返回报文
		OrderVo orderVo = new OrderVo();
		orderVo.setOrderNo(order.getOrderNo());
		orderVo.setGoods(orderSkuVo);
		orderVo.setConpon(orderCouponVo);
		orderVo.setActulAmt(order.getActualAmt());
		orderVo.setAddress(orderAddress);
		orderVo.setPayTime(order.getPayTime());
		orderVo.setPayNo(order.getPayNo());
		orderVo.setDeliveryNo(order.getDeliveryNo());
		orderVo.setDeliveryTime(order.getDeliveryTime());
		orderVo.setCreateTime(order.getCreateTime());

		//设置订单状态
		switch (Integer.valueOf(order.getOrderStatus())) {
//		case 1:	//未支付
//			orderVo.setStatus(ApiFeildCode.API_ORDER_STATUS_NOTPAY.getCode());
//			break;
//		case 4: //待发货
//			orderVo.setStatus(ApiFeildCode.API_ORDER_STATUS_ACCEPT.getCode());
//			break;
//		case 5: //已发货
//			orderVo.setStatus(ApiFeildCode.API_ORDER_STATUS_DELIVERY.getCode());
//			break;
//		case 6: //已收货
//			orderVo.setStatus(ApiFeildCode.API_ORDER_STATUS_SUCCESS.getCode());
//			break;
//		case 7: //已撤销
//			orderVo.setStatus(ApiFeildCode.API_ORDER_STATUS_CANCEL.getCode());
//			break;
//		case 2: //已关闭
//			orderVo.setStatus(ApiFeildCode.API_ORDER_STATUS_SHUT.getCode());
//			break;

		default:
			break;
		}
		
		orderVo.setCreateTime(order.getCreateTime());
		
		return orderVo;
	}
}

	